#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include "oxford-task.h"

using namespace Oxford;

Task::Task(const Word& word)
{
    _word = word;

    _initialize();
}

void Task::_initialize()
{
    _type = (TaskType)(qrand() % (_word.idioms().isEmpty() ? 2 : 4));

    switch (_type)
    {
    case WordFromDefinition:
        _generateWordFromDefinitionTask();
        break;
    case WordInSentenceFromDefinition:
        _generateWordInSentenceFromDefinitionTask();
        break;
    case IdiomFromDefinition:
        _generateIdiomFromDefinitionTask();
        break;
    case IdiomInSentenceFromDefinition:
        _generateIdiomInSentenceFromDefinitionTask();
        break;
    };
}

void Task::_generateWordFromDefinitionTask()
{
    _definition = _word.variants()[qrand() % _word.variants().count()].usageRule();
    _sentence = "";
    _answer = _word.word();
}

void Task::_generateWordInSentenceFromDefinitionTask()
{
    // TODO: implement this
//    int definitionId = qrand() % _word.variants().count();
//    int sentenceId = qrand() % _word.variants()[definitionId].examples().count();
//    _definition = _word.variants()[definitionId].usageRule();
//    _sentence = _word.variants()[definitionId].examples()[sentenceId].sentence;
//    _answer = _word.word();
}

void Task::_generateIdiomFromDefinitionTask()
{
    // TODO: implement this
}

void Task::_generateIdiomInSentenceFromDefinitionTask()
{
    // TODO: implement this
}
